
<div class="main-body">
		<div class='panel'>
			<div class='header'>
				<span class='col_fade'>编辑文章</span>
			</div>
			<form id='create_article_form' action='/article/<%=article.id%>/modify' method='post'  onsubmit="return check();">
			<div class='inner'>				
					<div>
						<label class='bold' for='title'>标题</label>
						<div>
							<input class='span8' id='title' name='title' maxlength='100' style='width:550px' value='<%= article.title %>'>
							字数在8到100个之间
						</div>
					</div>
					<div class='sep10'></div>
					<div class='sep10'></div>
					<div>
						<label class='bold' for='t_content'>内容和标签</label>
						<div class='tabbable'>
								<div style='width: 698px;height:40px;padding:10px 0;'><%- partial('article/category_selectable',{collection:categories, as:'category'}) %></div>
								<div class='input'>
									<textarea id="editor"  name='content' rows='20' style='width:700px;height:auto;'><%= article.content %></textarea>
								</div>
						</div>
					</div>
					<input type='hidden' id='article_categories' name='article_categories' value=''></input>
					<input type='hidden' name='_csrf' value='<%= csrf %>' />
					<div class='sep10'></div>
					<div class='sep10'></div>
					<div class='form-actions'>
						<input type='submit' id='submit_btn' class='btn' value="修改并提交"/>
					</div>
			</div>
			
			</form>
		</div>



	<script type='text/javascript'>
		    window.UEDITOR_CONFIG.minFrameHeight=500;
			var editor = new baidu.editor.ui.Editor();
			editor.render('editor');
		    function check(){
		        editor.sync();//同步
		        var values=[];
				$('.category_selectable').each(function(){
					if($(this).hasClass('category_select')){
						values.push($(this).attr('tag_id'));
					}
				});
				$('#article_categories').val(values);
				if(document.getElementById('title').value.length >100 || document.getElementById('title').value.length <8){
		   		 	alert('标题字数须在8-100之间');
		   		    return false;
		   		}
		   		else if(document.getElementById('article_categories').value==''){
		   		 	alert('请至少选择一个分类');
		   		    return false;
		   		}
		   		else{
		   		 	return true;
		   		}
		    }
		    
			$('.category_selectable').click(function(){
				$(this).toggleClass('category_select');
			});
	
	</script>

</div>
<%-partial('user/profile',{object:locals.current_user.id, as:'user_id'})%>